package study;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
	        ArrayList<Student> array = new ArrayList<>();
	        
	        while (true) {
	            System.out.println("------欢迎来到学生选课系统---------");
	            System.out.println("1.添加课程信息");
	            System.out.println("2.删除课程信息");
	            System.out.println("3.修改课程信息");
	            System.out.println("4.查看所有课程信息");
	            System.out.println("5.退出");
	            System.out.println("6.查询教师是否开课");
	            System.out.println("请输入你的选择:");
	            Scanner sc = new Scanner(System.in);
	            int num = sc.nextInt();
	            if (num == 1) {
	                addStudent(array);
	            }else if (num ==2) {
	                delStudent(array);
	            }else if (num == 3) {
	                updStudent(array);
	            }else if (num == 4) {
	                showAllStudent(array);
	            }else if (num == 6) {
	            	main1(array);
	            }else if (num == 5) {
	                break;
	            }else {
	                System.out.println("输入错误请重新输入");
	            }
	        }
	 
	    }
	    //定义一个方法，用于添加选课信息
	    public static void addStudent(ArrayList<Student> array){
	        Student s = new Student();
	        Scanner sc = new Scanner(System.in);
	        System.out.println("请输入课程名称");
	        String name = sc.nextLine();
	        System.out.println("请输入课程编号");
	        String num = sc.nextLine();
	        System.out.println("请输入上课时间");
	        String age = sc.nextLine();
	        System.out.println("请输入上课地点");
	        String address = sc.nextLine();
	        s.setName(name);s.setNum(num);s.setAge(age);s.setAddress(address);
	        array.add(s);
	        System.out.println("添加选课成功");
	    }
	    //定义一个方法，用于删除课程信息
	    public static void delStudent(ArrayList<Student> array){
	        Scanner sc = new Scanner(System.in);
	        System.out.println("请输入你要删除课程的编号:");
	        String id = sc.nextLine();
	        for (int i = 0; i<array.size();i++) {
	            Student s = array.get(i);
	            if (id.equals(s.getNum())) {
	                array.remove(i);
	                System.out.println("删除成功");
	            }else {
	                System.out.println("没有该课程编号");
	            }
	        }
	 
	    }
	    //定义一个方法，用于修改课程信息
	    public static void updStudent(ArrayList<Student> array){
	        Scanner sc = new Scanner(System.in);
	        System.out.println("请输入要修改的课程的编号:");
	        String id  = sc.nextLine();
	        for (int i = 0; i<array.size();i++) {
	            Student s = array.get(i);
	            if (id.equals(s.getNum())) {
	                System.out.println("请输入课程名称:");
	                String name = sc.nextLine();
	                System.out.println("请输入课程编号:");
	                String num = sc.nextLine();
	                System.out.println("请输入上课时间:");
	                String age = sc.nextLine();
	                System.out.println("请输入上课地点:");
	                String address = sc.nextLine();
	                s.setName(name);s.setNum(num);s.setAge(age);s.setAddress(address);
	                System.out.println("修改成功");
	            }
	        }
	    }
	    //定义一个方法，用于查看所有学生课程信息
	    public static void showAllStudent(ArrayList<Student> array){
	        System.out.println("课程名称    课程编号        课程时间     上课地点");
	        for (int i = 0; i<array.size();i++) {
	            Student s = array.get(i);
	            System.out.print(s.getName() + "    " + s.getNum()+ "    " +s.getAge()+ "      " +s.getAddress()+"\n");
	        }}
ArrayList<Course> array1 = new ArrayList<>();
public static void main1(ArrayList<Student> array){
    List<String>list = new ArrayList<String>();
    list.add("英语翻译 101 周一 韩老师");  //向列表中添加数据
    list.add("数码概论 102 周二 郑老师");  //向列表中添加数据
    list.add("临床医学 103 周三 张老师");  //向列表中添加数据
    String ret = "高等数学"; 
    for (int i = 0; i < list.size(); i++) {    //通过循环输出列表中的内容
        System.out.println(i + ":" + list.get(i));
        }
    System.out.println("教师是否开课" + ret + ":" + list.contains(ret));
    //判断字符串中是否包含指定字符串对象
    }




	private static void add(Course a) {
		
		// TODO 自动生成的方法存根
		
	}

	{
}}

	        


